package com.king.springcloud.service;

import com.king.springcloud.entities.CommonResult;
import com.king.springcloud.entities.PaymentEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @author king
 * @date 2020/9/10 22:57
 */
@Component
@FeignClient(value = "CLOUD-PROVIDER-HYSTRIX-PAYMENT", fallback = PaymentFallbackService.class)
public interface PaymentHystrixService {

    /**
     * 正常访问
     * @param id id
     * @return 结果
     */
    @GetMapping("/payment/hystrix/ok/{id}")
    String paymentInfoOK(@PathVariable("id") Integer id);

    /**
     * 异常访问
     * @param id id
     * @return 结果
     */
    @GetMapping("/payment/hystrix/timeout/{id}")
    String paymentInfoTimeout(@PathVariable("id")Integer id);

    /**
     * 超时补救
     *  HystrixCommand
     *      fallbackMethod 出错调用补救方法
     *      commandProperties
     *          HystrixProperty 响应峰值设置, 超过则调用补救方法
     * @param id id
     * @return 结果
     */
    @GetMapping("/payment/hystrix/timeout3/{id}")
    String paymentInfoTimeout3(@PathVariable("id")Integer id);
}
